import os


class PrjInfo():
    def __init__(self, record_path):
        self.record_path = record_path

    def get_prj_name(self):
        if not os.path.exists(self.record_path) and os.path.isdir(self.record_path):
            return -1
        project_name = []
        if os.path.exists(self.record_path):
            project_name = os.listdir(self.record_path)
        return project_name

    def get_test_items(self):
        project_name = self.get_prj_name()
        prj_info = {}
        for i in project_name:
            file = os.listdir(os.path.join(self.record_path, i))
            for j in file:
                if '.csv' in j:
                    file.remove(j)
            prj_info[i] = file
        return prj_info


def all_prj(record_path):
    prj = PrjInfo(record_path).get_test_items()
    all_prj = {}
    for k, v in prj.items():
        case_path = os.path.join(record_path, k)
        for i in v:
            model_path = os.path.join(case_path, i)
            case_list = os.listdir(model_path)
            all_prj.update({model_path: case_list})
    return all_prj
